mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
windows fixes
This commit is contained in:
parent
39b10f0dc8
commit
29230921e6
3
.github/workflows/windows.yml
vendored
3
.github/workflows/windows.yml
vendored
@ -36,6 +36,9 @@ jobs:
|
||||
- name: zig version
|
||||
run: zig version
|
||||
|
||||
- name: install rust nightly 1.64
|
||||
run: rustup install nightly-2022-08-06
|
||||
|
||||
- name: set up llvm 13
|
||||
run: |
|
||||
curl.exe -L -O https://github.com/roc-lang/llvm-package-windows/releases/download/v13.0.1/LLVM-13.0.1-win64.7z
|
||||
|
@ -186,11 +186,15 @@ pub fn build_zig_host_native(
|
||||
opt_level: OptLevel,
|
||||
shared_lib_path: Option<&Path>,
|
||||
) -> Command {
|
||||
// to prevent `clang failed with stderr: zig: error: unable to make temporary file: No such file or directory`
|
||||
let env_userprofile = env::var("USERPROFILE").unwrap_or_else(|_| "".to_string());
|
||||
|
||||
let mut zig_cmd = zig();
|
||||
zig_cmd
|
||||
.env_clear()
|
||||
.env("PATH", env_path)
|
||||
.env("HOME", env_home);
|
||||
.env("HOME", env_home)
|
||||
.env("USERPROFILE", env_userprofile);
|
||||
|
||||
if let Some(shared_lib_path) = shared_lib_path {
|
||||
zig_cmd.args(&[
|
||||
@ -419,7 +423,7 @@ pub fn build_c_host_native(
|
||||
dest,
|
||||
sources[0],
|
||||
find_zig_str_path().to_str().unwrap(),
|
||||
"x86_64-windows-gnu",
|
||||
get_target_str(target),
|
||||
opt_level,
|
||||
Some(shared_lib_path),
|
||||
);
|
||||
@ -578,23 +582,16 @@ pub fn rebuild_host(
|
||||
shared_lib_path,
|
||||
)
|
||||
}
|
||||
Architecture::X86_64 => {
|
||||
let target = match target.operating_system {
|
||||
OperatingSystem::Windows => "x86_64-windows-gnu",
|
||||
_ => "native",
|
||||
};
|
||||
|
||||
build_zig_host_native(
|
||||
Architecture::X86_64 => build_zig_host_native(
|
||||
&env_path,
|
||||
&env_home,
|
||||
host_dest.to_str().unwrap(),
|
||||
zig_host_src.to_str().unwrap(),
|
||||
zig_str_path.to_str().unwrap(),
|
||||
target,
|
||||
get_target_str(target),
|
||||
opt_level,
|
||||
shared_lib_path,
|
||||
)
|
||||
}
|
||||
),
|
||||
Architecture::X86_32(_) => build_zig_host_native(
|
||||
&env_path,
|
||||
&env_home,
|
||||
@ -636,7 +633,7 @@ pub fn rebuild_host(
|
||||
// on windows, we need the nightly toolchain so we can use `-Z export-executable-symbols`
|
||||
// using `+nightly` only works when running cargo through rustup
|
||||
let mut cmd = rustup();
|
||||
cmd.args(["run", "nightly", "cargo"]);
|
||||
cmd.args(["run", "nightly-2022-08-06", "cargo"]);
|
||||
|
||||
cmd
|
||||
} else {
|
||||
@ -807,6 +804,16 @@ pub fn rebuild_host(
|
||||
host_dest
|
||||
}
|
||||
|
||||
fn get_target_str(target: &Triple) -> &str {
|
||||
if target.operating_system == OperatingSystem::Windows
|
||||
&& target.environment == target_lexicon::Environment::Gnu
|
||||
{
|
||||
"x86_64-windows-gnu"
|
||||
} else {
|
||||
"native"
|
||||
}
|
||||
}
|
||||
|
||||
fn nix_path_opt() -> Option<String> {
|
||||
env::var_os("NIX_GLIBC_PATH").map(|path| path.into_string().unwrap())
|
||||
}
|
||||
@ -1227,7 +1234,7 @@ fn link_wasm32(
|
||||
}
|
||||
|
||||
fn link_windows(
|
||||
_target: &Triple,
|
||||
target: &Triple,
|
||||
output_path: PathBuf,
|
||||
input_paths: &[&str],
|
||||
link_type: LinkType,
|
||||
@ -1263,7 +1270,7 @@ fn link_windows(
|
||||
.args(input_paths)
|
||||
.args([
|
||||
"-target",
|
||||
"x86_64-windows-gnu",
|
||||
get_target_str(target),
|
||||
"--subsystem",
|
||||
"console",
|
||||
"-lc",
|
||||
@ -1386,7 +1393,8 @@ fn run_build_command(mut command: Command, file_to_build: &str, flaky_fail_count
|
||||
match std::str::from_utf8(&cmd_output.stderr) {
|
||||
Ok(stderr) => {
|
||||
// flaky error seen on macos 12 apple silicon, related to https://github.com/ziglang/zig/issues/9711
|
||||
if stderr.contains("unable to save cached ZIR code") && flaky_fail_counter < max_flaky_fail_count {
|
||||
if stderr.contains("unable to save cached ZIR code") {
|
||||
if flaky_fail_counter < max_flaky_fail_count {
|
||||
run_build_command(command, file_to_build, flaky_fail_counter + 1)
|
||||
} else {
|
||||
internal_error!(
|
||||
@ -1397,13 +1405,14 @@ fn run_build_command(mut command: Command, file_to_build: &str, flaky_fail_count
|
||||
stderr
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
internal_error!(
|
||||
"Error:\n Failed to rebuild {}:\n The executed command was:\n {}\n stderr of that command:\n {}",
|
||||
file_to_build,
|
||||
cmd_str,
|
||||
stderr
|
||||
)
|
||||
}
|
||||
},
|
||||
Err(utf8_err) => internal_error!(
|
||||
"Error:\n Failed to rebuild {}:\n The executed command was:\n {}\n stderr of that command could not be parsed as valid utf8:\n {}",
|
||||
|
@ -1,10 +1,17 @@
|
||||
[toolchain]
|
||||
channel = "1.64.0" # when changing this, update the date below with the last nightly with matching version using the link below
|
||||
# https://github.com/oxalica/rust-overlay/tree/master/manifests/nightly/2022
|
||||
# How to update version:
|
||||
# - update `channel = "RUST_VERSION"`
|
||||
# - to update the nightly version:
|
||||
# - Find the latest nightly release that matches RUST_VERSION here: https://github.com/oxalica/rust-overlay/tree/master/manifests/nightly/2022
|
||||
# - update `channel = "nightly-OLD_DATE"` below
|
||||
# - update nightly-OLD_DATE in .github/workflows/windows.yml
|
||||
# - update nightly-OLD_DATE in crates/compiler/build/src/link.rs
|
||||
|
||||
channel = "1.64.0" # check ^^^ when changing this
|
||||
#
|
||||
# channel = "nightly-2022-08-06" # 1.64 nightly to be able to use unstable features
|
||||
profile = "default"
|
||||
components = [
|
||||
# for usages of rust-analyzer or similar tools inside `nix develop`
|
||||
"rust-src"
|
||||
]
|
||||
targets = [ "x86_64-unknown-linux-gnu" ]
|
||||
|
Loading…
Reference in New Issue
Block a user