Skip to content

Windows fixes #1195

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

Closed
wants to merge 12 commits into from
Closed
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
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,21 @@ jobs:
rustc y.rs -o y.exe -g
./y.exe prepare

- name: Build
#name: Test
- name: Test
shell: bash
run: |
# Enable backtraces for easier debugging
#export RUST_BACKTRACE=1
export RUST_BACKTRACE=1

# Reduce amount of benchmark runs as they are slow
#export COMPILE_RUNS=2
#export RUN_RUNS=2
export COMPILE_RUNS=2
export RUN_RUNS=2

# Enable extra checks
#export CG_CLIF_ENABLE_VERIFIER=1
export CG_CLIF_ENABLE_VERIFIER=1

./y.exe build
rustup run nightly-2022-03-25 bash -c 'env'
rustup run nightly-2022-03-25 bash ./test.sh

- name: Package prebuilt cg_clif
# don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
Expand Down
2 changes: 1 addition & 1 deletion build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) fn build_sysroot(
build_cargo_wrapper_cmd
.arg("scripts/cargo-clif.rs")
.arg("-o")
.arg(target_dir.join("cargo-clif"))
.arg(target_dir.join(if cfg!(windows) { "cargo-clif.exe" } else { "cargo-clif" }))
.arg("-g");
spawn_and_wait(build_cargo_wrapper_cmd);

Expand Down
2 changes: 1 addition & 1 deletion build_system/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) fn prepare() {
fs::copy(
Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin")),
// FIXME use get_file_name here too once testing is migrated to rust
"simple-raytracer/raytracer_cg_llvm",
"simple-raytracer/raytracer_cg_llvm.exe",
)
.unwrap();
}
Expand Down
45 changes: 45 additions & 0 deletions patches/0003-rand-Disable-failing-test-on-windows.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 575b9b3bfe79dd4e5c0f66e62ed44b545ca5a217 Mon Sep 17 00:00:00 2001
From: bjorn3 <[email protected]>
Date: Sat, 26 Mar 2022 11:16:56 +0100
Subject: [PATCH] Disable failing test on windows

---
rand_distr/src/pareto.rs | 1 +
rand_distr/tests/value_stability.rs | 2 ++
2 files changed, 3 insertions(+)

diff --git a/rand_distr/src/pareto.rs b/rand_distr/src/pareto.rs
index 217899e..9830585 100644
--- a/rand_distr/src/pareto.rs
+++ b/rand_distr/src/pareto.rs
@@ -107,6 +107,7 @@ mod tests {
}

#[test]
+ #[cfg_attr(windows, ignore)]
fn value_stability() {
fn test_samples<F: Float + core::fmt::Debug, D: Distribution<F>>(
distr: D, zero: F, expected: &[F],
diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs
index 192ba74..b98bef0 100644
--- a/rand_distr/tests/value_stability.rs
+++ b/rand_distr/tests/value_stability.rs
@@ -72,6 +72,7 @@ fn unit_disc_stability() {
}

#[test]
+#[cfg_attr(windows, ignore)]
fn pareto_stability() {
test_samples(213, Pareto::new(1.0, 1.0).unwrap(), &[
1.0423688f32, 2.1235929, 4.132709, 1.4679428,
@@ -143,6 +144,7 @@ fn inverse_gaussian_stability() {
}

#[test]
+#[cfg_attr(windows, ignore)]
fn gamma_stability() {
// Gamma has 3 cases: shape == 1, shape < 1, shape > 1
test_samples(223, Gamma::new(1.0, 5.0).unwrap(), &[
--
2.26.2.7.g19db9cfb68

1 change: 1 addition & 0 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ set -e

export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$(rustc --print sysroot)/lib:$DYLD_LIBRARY_PATH"
ls $(rustc --print sysroot)/bin
4 changes: 4 additions & 0 deletions scripts/ext_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
fi
fi

if echo "$HOST_TRIPLE" | grep -q "windows"; then
export JIT_SUPPORTED=0 # FIXME jit mode is broken on Windows
fi

# FIXME fix `#[linkage = "extern_weak"]` without this
if [[ "$(uname)" == 'Darwin' ]]; then
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
Expand Down
12 changes: 7 additions & 5 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ set -e
source scripts/config.sh
source scripts/ext_config.sh
export RUSTC=false # ensure that cg_llvm isn't accidentally used
MY_RUSTC="$(pwd)/build/bin/cg_clif $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
MY_RUSTC="$(pwd)/build/bin/cg_clif.exe $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"

function no_sysroot_tests() {
ls build/bin

echo "[BUILD] mini_core"
$MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"

Expand Down Expand Up @@ -96,13 +98,13 @@ function extended_sysroot_tests() {
pushd simple-raytracer
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
echo "[BENCH COMPILE] ebobby/simple-raytracer"
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif clean" \
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif.exe clean" \
"RUSTC=rustc RUSTFLAGS='' cargo build" \
"../build/cargo-clif build"
"../build/cargo-clif.exe build"

echo "[BENCH RUN] ebobby/simple-raytracer"
cp ./target/debug/main ./raytracer_cg_clif
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
cp ./target/debug/main.exe ./raytracer_cg_clif.exe
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm.exe ./raytracer_cg_clif.exe
else
../build/cargo-clif clean
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ impl<'tcx> CodegenCx<'tcx> {

let unwind_context =
UnwindContext::new(isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
let debug_context = if debug_info { Some(DebugContext::new(tcx, isa)) } else { None };
let debug_context = if debug_info && !tcx.sess.target.options.is_like_windows {
Some(DebugContext::new(tcx, isa))
} else {
None
};
CodegenCx {
tcx,
global_asm: String::new(),
Expand Down
6 changes: 2 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash
set -e

./y.rs build --sysroot none "$@"

rm -r target/out || true
./y.exe build --sysroot none "$@"

scripts/tests.sh no_sysroot

./y.rs build "$@"
./y.exe build "$@"

scripts/tests.sh base_sysroot
scripts/tests.sh extended_sysroot